package com.zlj.request.forward;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 演示请求转发：
 * 一个请求，涉及多个servlet，至少两个servlet，留头不留体
 * 
 */
@WebServlet("/ForwardOneServlet")
public class ForwardOneServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         System.out.println("One Servlet");
         response.getWriter().print("One Servlet Forward");  //因为不留体，所以不会显示到页面中
         
         request.setAttribute("username", "zhangsan");
         
         request.getRequestDispatcher("/ForwardTwoServlet").forward(request, response);
	}
}
